﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharpSvn;
using System.Collections.ObjectModel;
using CommonDataType;

namespace SvnCSharpClientInterFace
{
    public class SvnCSharpClient
    {

        //获取备注信息
        string getLogMessage(Uri uri)
        {
            SvnClient client = new SvnClient();
            Collection<SvnLogEventArgs> col;
            SvnLogArgs la = new SvnLogArgs();

     

            List<string> files = new List<string>();

            if (client.GetLog(uri, la, out col))
            {
                foreach (SharpSvn.SvnLogEventArgs item in col)
                {
                    string strLog = item.LogMessage;
                    return strLog;
                }
            }
            return "";
        }

        //函数功能：
        //      通过uml获取路径下的所有子目录
        public
        bool getVersionInformationList(string strUml, ref VersionList versionList, ref string strMesg)
        {
            SvnClient client = new SvnClient();

            Collection<SvnInfoEventArgs> contents;

            SvnInfoArgs args = new SvnInfoArgs();
            args.Depth = SvnDepth.Children;

            if (client.GetInfo(new Uri(strUml), args, out contents))
            {
                foreach (SvnInfoEventArgs item in contents)
                {
                    VersionInformation version = new VersionInformation();
                    //版本号
                    version.m_lVersionNumber = item.LastChangeRevision;
                    //版本类别
                    version.m_enVersionType = "project";
                    //version
                    version.m_strPersionName = item.LastChangeAuthor;
                    //日期
                    version.m_strDate = item.LastChangeTime.ToShortDateString(); 

                    //svn地址
                    version.m_strUri = item.Uri.ToString();

                    //备注信息
                    version.m_strNote = getLogMessage(item.Uri);

                    versionList.Add( version );
                }
            }
            return true;
        }
    }
}
